<?php

$id_cladire = "16"; 

$query = mysql_query("SELECT * FROM unitati WHERE `tip` >= 2 AND planeta = '".$planeta."' AND locatie = 'disponibili'");
$query2 = mysql_query("SELECT * FROM actiuni_globale WHERE dest_planeta = '".$planeta."' OR exp_planeta = '".$planeta."' ORDER BY durata DESC");
echo '<table class="font_2">';
while($rez_16 = mysql_fetch_array($query2))
{
$id = $rez_16["id"];
$planeta_exp = $rez_16["exp_planeta"];
$planeta_dest = $rez_16["dest_planeta"];
$expeditor = valoare_mysql("SELECT user FROM planete WHERE id = '".$planeta_exp."'");
$destinatar = valoare_mysql("SELECT user FROM planete WHERE id = '".$planeta_dest."'");
$tip = $rez_16["tip"];
$valoare = $rez_16["valoare"];
$incepere = $rez_16["incepere"];
$durata = $rez_16["durata"];
$date_sum = verificare_data($incepere, $durata, "term");
$timp = calculare_sec(time(), $date_sum, "sec");
 if ($timp<0)
  $timp = 0;
if ($expeditor == $user && $tip != 'intoarcere') {
$user_id = mysql_fetch_row(mysql_query("SELECT `id` FROM `users` WHERE `user` = '".$destinatar."'"));
echo "<tr><td><a href=\"javascript:void(0)\" onClick=\"javascript:optiuni_structura('".$id_cladire."', '".$id."')\"><img src=\"img/ico_anuleaza.png\" alt=\"anulare\" border=\"0\" /><a/></td><td>".$tip." catre</td><td> <a href=\"javascript:void(0)\" onMouseUp=\"javascript:optiuni_utilizator('".$user_id[0]."');\" >".$destinatar."</a> in </td><td><i>".date("i:s",$timp)."</i> min.</td></tr>";
} else {
$user_id = mysql_fetch_row(mysql_query("SELECT `id` FROM `users` WHERE `user` = '".$expeditor."'"));
echo "<tr><td>&nbsp;</td><td>".$tip." de la</td><td> <a href=\"javascript:void(0)\" onMouseUp=\"javascript:optiuni_utilizator('".$user_id[0]."');\" >".$expeditor."</a> in </td><td><i>".date("i:s",$timp)."</i> min.</td></tr>";
}
}
echo "</table>";

echo "<form method=\"POST\" action=\"#\" onSubmit=\"javascript:return false;\" name=\"expediere_form\"><p>Trimite trupe:</p>";
echo "<div id=\"structura_offset\"><table class=\"font_2\">";
while($rez = mysql_fetch_array($query)) {
$query_c = mysql_fetch_row(mysql_query("SELECT nume FROM c_unitati WHERE `id` = '".$rez["tip"]."'"));
echo "<tr><td>".$query_c[0]."<input type=\"hidden\" value=\"".$rez["tip"]."\" name=\"expediere_unitati_tip\" /></td><td><input type=\"text\" value=\"0\" name=\"expediere_unitati_numar\" size=\"5\" maxlength=\"5\" /></td><td>(max. ".$rez["nr"].")<input type=\"hidden\" value=\"".$rez["nr"]."\" name=\"expediere_numar_max\" /></td></tr>";
}
echo "</table></div>";
echo "<p>Tip expeditie: ";
echo '<select name="tip_expediere"><option value="atac">Atac</option><option value="intariri">Intariri</option><option value="spionaj">Spionaj</option></select>';
echo '&nbsp;la x: <input type="text" size="3" maxlength="3" value="0" name="coord_x" /> y:<input type="text" size="3" maxlength="3" value="0" name="coord_y" />&nbsp;&nbsp;<input type="submit" value="Trimite" name="submit" onClick="javascript:optiuni_structura(\''.$id_cladire.'\', \'expediere\');" /></p></form></div>';

?>